package ${packageName}.service.impl;

import ${packageName}.bean.Pager;

import org.springframework.stereotype.Service;
import ${packageName}.service.${entity}Service;
import org.springframework.beans.factory.annotation.Autowired;

import ${packageName}.dao.extend.${entity}ExtendMapper;
import ${packageName}.entity.${entity};
import ${packageName}.dto.request.${entity}PagerRequest;


import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;

@Service
public class ${entity}ServiceImpl implements ${entity}Service{

    @Autowired
    private ${entity}ExtendMapper ${entityLowerCase}ExtendMapper;


    /**
     * 分页查询
     * @param request
     * @return
     */
    @Override
    public Pager<${entity}> find(${entity}PagerRequest request) {
        request.webParamConvert();
        List<${entity}> list = ${entityLowerCase}ExtendMapper.find(request);
        int totalCount = ${entityLowerCase}ExtendMapper.getTotalCount(request);
        Pager<${entity}> pager = new Pager<>();
        pager.setPageNumber(request.getPageNumber());
        pager.setPageSize(request.getPageSize());
        pager.setList(list);
        pager.setTotalCount(totalCount);
        return pager;
    }


    /**
     * 获取
     * @param id
     * @return
     */
    @Override
    public ${entity} get(Long id){
        return ${entityLowerCase}ExtendMapper.selectByPrimaryKey(id);
    }


    /**
     * 新增
     *
     * @param ${entityLowerCase}
     * @return
     */
    @Override
    public int add(${entity} ${entityLowerCase}) {
        return ${entityLowerCase}ExtendMapper.insertSelective(${entityLowerCase});
    }

    /**
     * 更新
     *
     * @param ${entityLowerCase}
     */
    @Override
    public void update(${entity} ${entityLowerCase}) {
        ${entityLowerCase}ExtendMapper.updateByPrimaryKeySelective(${entityLowerCase});
    }

    /**
     * 删除
     *
     * @param id
     */
    @Override
    public void delete(Long id) {
        ${entityLowerCase}ExtendMapper.deleteByPrimaryKey(id);
    }

}
